<?php

namespace App\Api\Controller;

use App\SunPicture;
use Illuminate\Http\Request;
use App\Api\Transformers\SunpictureAllTransformer;
use App\Api\Transformers\SunpictureContentTransformer;

class SunpictureController extends BaseController{
    public function index()
    {
        $sun_pic = SunPicture::all();
        return $this->response->collection($sun_pic , new SunpictureAllTransformer());
    }

    public function show(Request $request,$id){
        $sun_pic=SunPicture::where('id',$id)->get();
        if (!$sun_pic)
        {
            return $this->response->errorBadRequest('没有找到此帖子！');
        }else{
            return $this->response->item($sun_pic,new SunpictureContentTransformer());
        }
    }
}